const requset = require("./requset");

exports.getUser = function getUser(params) {
  return  requset({
    method: "get",
    url: `https://www.yuque.com/api/v2/user`
  });
}

exports.getRepos = function getRepos(userId) {
  return requset({
    method: "get",
    url: `https://www.yuque.com/api/v2/users/${userId}/repos`,
    params: {
      type: 'all'
    },
  });
}

exports.getDocs =function getDocs(docid) {
  return requset({
    method: "get",
    url: `https://www.yuque.com/api/v2/repos/${docid}/docs`,
    params: {},
  });
}

exports.getDocsDetails = function getDocsDetails(docid, slug) {
  return requset({
    method: "get",
    url: `https://www.yuque.com/api/v2/repos/${docid}/docs/${slug}`,
    params: {
      raw:1,
    },
  });
}